package com.pro.springbootshop.controller;

import com.pro.springbootshop.entity.MainClasses;
import com.pro.springbootshop.service.MainClassesService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MainClassesController {
    @Autowired
    MainClassesService mainClassesService;
    @ApiOperation("增加一个主类")
    @PostMapping("/api/mainClasses/{mainClassName}")
    public String saveMainClasses(@PathVariable(name = "mainClassName") String mainClassName){
        return mainClassesService.saveMainClasses(mainClassName);
    }
    @ApiOperation("删除一个主类")
    @PostMapping("/api/mainClasses/delete/{mainClassId}")
    public String deleteMainClasses(@PathVariable(name = "mainClassId") int mainClassId){
        return mainClassesService.deleteMainClasses(mainClassId);
    }
    @ApiOperation("查询所有主类并返回副类信息")
    @GetMapping("/api/classList")
    public List<MainClasses>  findAllByMain(){
        return mainClassesService.findAllByMain();
    }

}
